home *** CD-ROM | disk | FTP | other *** search
/ The 640 MEG Shareware Studio 2 / The 640 Meg Shareware Studio CD-ROM Volume II (Data Express)(1993).ISO / prog / pas_all.zip / TI994.ASC < prev    next >
Text File  |  1992-04-28  |  18KB  |  595 lines

  1.  
  2.  
  3.  
  4.  
  5.  
  6.  
  7.  
  8.   PRODUCT  :  Turbo Pascal                           NUMBER  :  994
  9.   VERSION  :  All
  10.        OS  :  DOS
  11.      DATE  :  April 28, 1992                           PAGE  :  1/9
  12.  
  13.     TITLE  :  Turbo Pascal vs ANSI Pascal
  14.  
  15.  
  16.  
  17.  
  18.  
  19.   =================================================================
  20.              Comparing Turbo Pascal 6.0 with ANSI Pascal
  21.   =================================================================
  22.  
  23.  
  24.   -----------------------------------------------------------------
  25.                             Table of Contents
  26.   -----------------------------------------------------------------
  27.  
  28.    1. Exceptions to ANSI Pascal requirements
  29.    2. Extensions to ANSI Pascal
  30.    3. Implementation-dependent features
  31.    4. Treatment of errors
  32.   -----------------------------------------------------------------
  33.  
  34.        This appendix compares Turbo Pascal to ANSI Pascal as
  35.        defined by ANSI/IEEE770X3.97-1983 in the book American
  36.        National Standard Pascal Computer Programming Language (ISBN
  37.        0-471-88944-X, published by The Institute of Electrical and
  38.        Electronics Engineers in New York).
  39.  
  40.  
  41.   ===========================================
  42.    1. Exceptions to ANSI Pascal requirements
  43.   ===========================================
  44.  
  45.        Turbo Pascal is unable to detect whether a program violates
  46.        any of the exceptions listed here.
  47.  
  48.        Turbo Pascal complies with the requirements of
  49.        ANSI/IEEE770X3.97-1983 with the following exceptions:
  50.  
  51.        o In ANSI Pascal, an identifier can be of any length and all
  52.        characters are significant. In Turbo Pascal, an identifier
  53.        can be of any length, but only the first 63 characters are
  54.        significant.
  55.  
  56.        o In ANSI Pascal, the @ symbol is an alternative for the ^
  57.        symbol.  In Turbo Pascal, the @ symbol is an operator,
  58.        which is never treated identically with the ^ symbol.
  59.  
  60.  
  61.  
  62.  
  63.  
  64.  
  65.  
  66.  
  67.  
  68.  
  69.  
  70.  
  71.  
  72.  
  73.  
  74.   PRODUCT  :  Turbo Pascal                           NUMBER  :  994
  75.   VERSION  :  All
  76.        OS  :  DOS
  77.      DATE  :  April 28, 1992                           PAGE  :  2/9
  78.  
  79.     TITLE  :  Turbo Pascal vs ANSI Pascal
  80.  
  81.  
  82.  
  83.  
  84.        o In ANSI Pascal, a comment can begin with { and end with
  85.        *), or begin with (* and end with }. In Turbo Pascal,
  86.        comments must begin and end with the same set of symbols.
  87.  
  88.        o In ANSI Pascal, each possible value of the tag type in a
  89.        variant part must appear once. In Turbo Pascal, this
  90.        requirement is not enforced.
  91.  
  92.        o In ANSI Pascal, the component type of a file type cannot
  93.        be a structured type having a component of a file type. In
  94.        Turbo Pascal, this requirement is not enforced.
  95.  
  96.        o In ANSI Pascal, a file variable has an associated buffer
  97.        variable, which is referenced by writing the ^ symbol after
  98.        the file variable. In Turbo Pascal, a file variable does not
  99.        have an associated buffer variable, and writing the ^ symbol
  100.        after a file variable is an error.
  101.  
  102.        o In ANSI Pascal, the statement part of a function must
  103.        contain at least one assignment to the function identifier.
  104.        In Turbo Pascal, this requirement is not enforced.
  105.  
  106.        o In ANSI Pascal, a field that is the selector of a variant
  107.        part cannot be an actual variable parameter. In Turbo
  108.        Pascal, this requirement is not enforced.
  109.  
  110.        o In ANSI Pascal, a component of a variable of a packed type
  111.        cannot be an actual variable parameter. In Turbo Pascal,
  112.        this requirement is not enforced.
  113.  
  114.        o In ANSI Pascal, a procedural or functional parameter is
  115.        declared by writing a procedure or function heading in the
  116.        formal parameter list. In Turbo Pascal, the declaration of a
  117.        procedural or functional parameter is achieved through a
  118.        procedural or functional type, and uses the same syntax as
  119.        the declaration of other types of parameters.
  120.  
  121.        o In ANSI Pascal, the standard procedures Reset and Rewrite
  122.        do not require pre-initialization of file variables. In
  123.        Turbo Pascal, file variables must be assigned the name of an
  124.        external file using the Assign procedure before they are
  125.        passed to Reset or Rewrite.
  126.  
  127.  
  128.  
  129.  
  130.  
  131.  
  132.  
  133.  
  134.  
  135.  
  136.  
  137.  
  138.  
  139.  
  140.   PRODUCT  :  Turbo Pascal                           NUMBER  :  994
  141.   VERSION  :  All
  142.        OS  :  DOS
  143.      DATE  :  April 28, 1992                           PAGE  :  3/9
  144.  
  145.     TITLE  :  Turbo Pascal vs ANSI Pascal
  146.  
  147.  
  148.  
  149.  
  150.        o ANSI Pascal defines the standard procedures Get and Put,
  151.        which are used to read from and write to files. These
  152.        procedures are not defined in Turbo Pascal.
  153.  
  154.        o In ANSI Pascal, the syntax New(p,c1,...,cn) creates a
  155.        dynamic variable with a specific active variant. In Turbo
  156.        Pascal, this syntax is not allowed.
  157.  
  158.        o In ANSI Pascal, the syntax Dispose(q,k1,...,km) removes a
  159.        dynamic variable with a specific active variant. In Turbo
  160.        Pascal, this syntax is not allowed.
  161.  
  162.        o ANSI Pascal defines the standard procedures Pack and
  163.        Unpack, which are used to "pack" and "unpack" packed
  164.        variables. These procedures are not defined in Turbo Pascal.
  165.  
  166.        o In ANSI Pascal, the term i mod j always computes a
  167.        positive value, and it is an error if j is zero or negative.
  168.        In Turbo Pascal, i mod j is computed as i - (i div j) * j,
  169.        and it is not an error if j is negative.
  170.  
  171.        o In ANSI Pascal, a goto statement within a block can refer
  172.        to a label in an enclosing block. In Turbo Pascal, this is
  173.        an error.
  174.  
  175.        o In ANSI Pascal, it is an error if the value of the
  176.        selector in a case statement is not equal to any of the case
  177.        constants. In Turbo Pascal, this is not an error; instead,
  178.        the case statement is ignored unless it contains an else
  179.        clause.
  180.  
  181.        o In ANSI Pascal, statements that threaten the control
  182.        variable of a for statement are not allowed. In Turbo
  183.        Pascal, this requirement is not enforced.
  184.  
  185.        o In ANSI Pascal, a Read from a text file with a Char-type
  186.        variable assigns a blank to the variable if Eoln was True
  187.        before the Read. In Turbo Pascal, a carriage return
  188.        character (ASCII 13) is assigned to the variable in this
  189.        situation.
  190.  
  191.        o In ANSI Pascal, a Read from a text file with an integer-
  192.        type or real-type variable ceases as soon as the next
  193.  
  194.  
  195.  
  196.  
  197.  
  198.  
  199.  
  200.  
  201.  
  202.  
  203.  
  204.  
  205.  
  206.   PRODUCT  :  Turbo Pascal                           NUMBER  :  994
  207.   VERSION  :  All
  208.        OS  :  DOS
  209.      DATE  :  April 28, 1992                           PAGE  :  4/9
  210.  
  211.     TITLE  :  Turbo Pascal vs ANSI Pascal
  212.  
  213.  
  214.  
  215.  
  216.        character in the file is not part of a signed integer or a
  217.        signed number. In Turbo Pascal, reading ceases when the next
  218.        character in the file is a blank or a control character
  219.        (including the end-of-line marker).
  220.  
  221.        o In ANSI Pascal, a Write to a text file with a packed
  222.        string-type value causes the string to be truncated if the
  223.        specified field width is less than the length of the string.
  224.        In Turbo Pascal, the string is always written in full, even
  225.        if it is longer than the specified field width.
  226.  
  227.        o ANSI Pascal defines the standard procedure Page, which
  228.        causes all subsequent output to a specific text file to be
  229.        written on a new page. This procedure is not defined in
  230.        Turbo Pascal. However, the typical equivalent of Page(F) is
  231.        Write(F,Chr(12)).
  232.  
  233.   ==============================
  234.    2. Extensions to ANSI Pascal
  235.   ==============================
  236.  
  237.        Turbo Pascal is unable to detect whether a program uses any
  238.        of the extensions listed here.
  239.  
  240.        The following Turbo Pascal features are extensions to Pascal
  241.        as specified by ANSI/IEEE770X3.97-1983.
  242.  
  243.        o The following are reserved words in Turbo Pascal:
  244.  
  245.          absolute              inline                 shr
  246.          assembler             interface              string
  247.          constructor           interrupt              unit
  248.          destructor            object                 virtual
  249.          external              private                uses
  250.          far                   near                   xor
  251.          implementation        shl
  252.  
  253.        o An identifier can contain underscore characters (_).
  254.  
  255.        o Integer constants can be written in hexadecimal notation;
  256.        such constants are prefixed by a $.
  257.  
  258.        o Identifiers can serve as labels.
  259.  
  260.  
  261.  
  262.  
  263.  
  264.  
  265.  
  266.  
  267.  
  268.  
  269.  
  270.  
  271.  
  272.   PRODUCT  :  Turbo Pascal                           NUMBER  :  994
  273.   VERSION  :  All
  274.        OS  :  DOS
  275.      DATE  :  April 28, 1992                           PAGE  :  5/9
  276.  
  277.     TITLE  :  Turbo Pascal vs ANSI Pascal
  278.  
  279.  
  280.  
  281.  
  282.        o String constants are compatible with the Turbo Pascal
  283.        string types, and can contain control characters and other
  284.        nonprintable characters.
  285.  
  286.        o Label, constant, type, variable, procedure, and function
  287.        declarations can occur any number of times in any order in a
  288.        block.
  289.  
  290.        o Wherever the syntax of ANSI Pascal requires a simple
  291.        constant, Turbo Pascal allows the use of a constant
  292.        expression (also known as a computed constant).
  293.  
  294.        o Turbo Pascal implements the additional integer types
  295.        Shortint, Longint, Byte, and Word, and the additional real
  296.        types Single, Double, Extended, and Comp.
  297.  
  298.        o Turbo Pascal implements string types, which differ from
  299.        the packed string types defined by ANSI Pascal in that they
  300.        include a dynamic-length attribute that can vary during
  301.        execution.
  302.  
  303.        o Turbo Pascal implements procedural and functional types.
  304.        In addition to procedural and functional parameters, these
  305.        types make possible the declaration and use of procedural
  306.        and functional variables.
  307.  
  308.        o The type compatibility rules are extended to make Char
  309.        types and packed string types compatible with string types.
  310.  
  311.        o Variables can be declared at absolute memory addresses
  312.        using an absolute clause.
  313.  
  314.        o A variable reference can contain a call to a pointer-type
  315.        function, the result of which is then dereferenced to denote
  316.        a dynamic variable.
  317.  
  318.        o String-type variables can be indexed as arrays to access
  319.        individual characters in a string.
  320.  
  321.        o The type of a variable reference can be changed to another
  322.        type through a variable typecast.
  323.  
  324.  
  325.  
  326.  
  327.  
  328.  
  329.  
  330.  
  331.  
  332.  
  333.  
  334.  
  335.  
  336.  
  337.  
  338.   PRODUCT  :  Turbo Pascal                           NUMBER  :  994
  339.   VERSION  :  All
  340.        OS  :  DOS
  341.      DATE  :  April 28, 1992                           PAGE  :  6/9
  342.  
  343.     TITLE  :  Turbo Pascal vs ANSI Pascal
  344.  
  345.  
  346.  
  347.  
  348.        o Turbo Pascal implements typed constants, which can be used
  349.        to declare initialized variables of all types except file
  350.        types.
  351.  
  352.        o Turbo Pascal implements three new logical operators: xor,
  353.        shl, and shr.
  354.  
  355.        o The not, and, or, and xor operators can be used with
  356.        integer-type operands to perform bitwise logical operations.
  357.  
  358.        o The + operator can be used to concatenate strings.
  359.  
  360.        o The relational operators can be used to compare strings.
  361.  
  362.        o Turbo Pascal implements the @ operator, which is used to
  363.        obtain the address of a variable or a procedure or function.
  364.  
  365.        o The type of an expression can be changed to another type
  366.        through a value typecast.
  367.  
  368.        o The case statement allows constant ranges in case label
  369.        lists, and provides an optional else part.
  370.  
  371.        o Procedures and functions can be declared with external,
  372.        inline, and interrupt directives to support assembly
  373.        language subroutines, inline machine code, and interrupt
  374.        procedures.
  375.  
  376.        o A variable parameter can be untyped (typeless), in which
  377.        case any variable reference can serve as the actual
  378.        parameter.
  379.  
  380.        o Turbo Pascal implements units to facilitate modular
  381.        programming and separate compilation.
  382.  
  383.        o Turbo Pascal implements the following file-handling
  384.        procedures and functions, which are not available in ANSI
  385.        Pascal:
  386.  
  387.          Append               FilePos                 Rename
  388.          BlockRead            FileSize                RmDir
  389.          BlockWrite           Flush                   Seek
  390.          ChDir                GetDir                  SeekEof
  391.  
  392.  
  393.  
  394.  
  395.  
  396.  
  397.  
  398.  
  399.  
  400.  
  401.  
  402.  
  403.  
  404.   PRODUCT  :  Turbo Pascal                           NUMBER  :  994
  405.   VERSION  :  All
  406.        OS  :  DOS
  407.      DATE  :  April 28, 1992                           PAGE  :  7/9
  408.  
  409.     TITLE  :  Turbo Pascal vs ANSI Pascal
  410.  
  411.  
  412.  
  413.  
  414.          Close                MkDir                   SeekEoln
  415.          Erase
  416.  
  417.        o String-type values can be input and output with the Read,
  418.        Readln, Write, and Writeln standard procedures.
  419.  
  420.        o Turbo Pascal implements the following standard procedures
  421.        and functions, which are not found in ANSI Pascal:
  422.  
  423.          Addr                 Inc                    Ptr
  424.          Concat               Insert                 Random
  425.          Copy                 Int                    Randomize
  426.          CSeg                 Length                 Release
  427.          DSeg                 Lo                     RunError
  428.          Dec                  Mark                   SPtr
  429.          Delete               MaxAvail               Seg
  430.          Exit                 MemAvail               SizeOf
  431.          FillChar             Move                   SSeg
  432.          Frac                 Ofs                    Str
  433.          FreeMem              ParamCount             Swap
  434.          GetMem               ParamStr               TypeOf
  435.          Halt                 Pi                     UpCase
  436.          Hi                   Pos                    Val
  437.  
  438.        o Turbo Pascal implements further standard constants, types,
  439.        variables, procedures, and functions through standard units.
  440.  
  441.  
  442.   ======================================
  443.    3. Implementation-dependent features
  444.   ======================================
  445.  
  446.        The effect of using an implementation-dependent feature of
  447.        Pascal, as defined by ANSI/IEEE770X3.97-1983, is
  448.        unspecified.  Programs should not depend on any specific
  449.        path being taken in cases where an implementation-dependent
  450.        feature is being used.  Implementation-dependent features
  451.        include:
  452.  
  453.        o the order of evaluation of index expressions in a variable
  454.        reference
  455.  
  456.  
  457.  
  458.  
  459.  
  460.  
  461.  
  462.  
  463.  
  464.  
  465.  
  466.  
  467.  
  468.  
  469.  
  470.   PRODUCT  :  Turbo Pascal                           NUMBER  :  994
  471.   VERSION  :  All
  472.        OS  :  DOS
  473.      DATE  :  April 28, 1992                           PAGE  :  8/9
  474.  
  475.     TITLE  :  Turbo Pascal vs ANSI Pascal
  476.  
  477.  
  478.  
  479.  
  480.        o the order of evaluation of expressions in a set
  481.        constructor
  482.  
  483.        o the order of evaluation of operands of a binary operator
  484.  
  485.        o the order of evaluation of actual parameters in a function
  486.        call
  487.  
  488.        o the order of evaluation of the left and right sides of an
  489.        assignment
  490.  
  491.        o the order of evaluation of actual parameters in a
  492.        procedure statement
  493.  
  494.        o the effect of reading a text file to which the procedure
  495.        Page was applied during its creation
  496.  
  497.        o the binding of variables denoted by the program parameters
  498.        to entities external to the program
  499.  
  500.  
  501.   ========================
  502.    4. Treatment of errors
  503.   ========================
  504.  
  505.        This section lists those errors from Appendix D of the ANSI
  506.        Pascal Standard that are not automatically detected by Turbo
  507.        Pascal. The numbers referred to here are the numbers used in
  508.        the ANSI Pascal Standard. Errors 6, 19-22, and 25-31 are not
  509.        detected because they are not applicable to Turbo Pascal.
  510.  
  511.        2. If t is a tag field in a variant part and f is a field
  512.        within the active variant of that variant part, it is an
  513.        error to alter the value of t while a reference to f exists.
  514.        This error is not detected.
  515.  
  516.        3. If p is a pointer variable, it is an error to reference
  517.        p^ if p is nil. This error is not detected.
  518.  
  519.        4. If p is a pointer variable, it is an error to reference
  520.        p^ if p is undefined. This error is not detected.
  521.  
  522.  
  523.  
  524.  
  525.  
  526.  
  527.  
  528.  
  529.  
  530.  
  531.  
  532.  
  533.  
  534.  
  535.  
  536.   PRODUCT  :  Turbo Pascal                           NUMBER  :  994
  537.   VERSION  :  All
  538.        OS  :  DOS
  539.      DATE  :  April 28, 1992                           PAGE  :  9/9
  540.  
  541.     TITLE  :  Turbo Pascal vs ANSI Pascal
  542.  
  543.  
  544.  
  545.  
  546.        5. If p is a pointer variable, it is an error to alter the
  547.        value of p while a reference to p^ exists. This error is not
  548.        detected.
  549.  
  550.        42. The function call Eoln(f) is an error if Eof(f) is True.
  551.        In Turbo Pascal this is not an error, and Eoln(f) is True
  552.        when Eof(f) is True.
  553.  
  554.        43. It is an error to reference a variable in an expression
  555.        if the value of that variable is undefined. This error is
  556.        not detected.
  557.  
  558.        46. A term of the form i mod j is an error if j is zero or
  559.        negative. In Turbo Pascal, it is not an error if j is
  560.        negative.
  561.  
  562.        48. It is an error if a function does not assign a result
  563.        value to the function identifier. This error is not
  564.        detected.
  565.  
  566.        51. It is an error if the value of the selector in a case
  567.        statement is not equal to any of the case constants. In
  568.        Turbo Pascal, this is not an error; instead, the case
  569.        statement is ignored unless it contains an else clause.
  570.  
  571.  
  572.  
  573.  
  574.  
  575.  
  576.  
  577.  
  578.  
  579.  
  580.  
  581.  
  582.  
  583.  
  584.  
  585.  
  586.  
  587.  
  588.  
  589.  
  590.  
  591.  
  592.  
  593.  
  594.  
  595.